import { Layers, Node, TTFFont, UITransform }  from "cc"


//工具类文件


//为什么要用箭头函数
export const createUINode=(name:string='')=>{
    const node = new    Node(name)
    const tf=node.addComponent(UITransform)
    tf.setAnchorPoint(0,1)

    node.layer=Layers.Enum.UI_2D
    
    return node
}


//瓦片随机函数
export const  randomByRange=(start:number , end:number)=>{
    return Math.floor(start+(end-start)*Math.random())
}


//生成随机字符串
export const randomByLength = (n: number) =>
  Array.from({ length: n }).reduce<string>((total: string) => total + Math.floor(Math.random() * 10), '')